package org;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

public class Weasel extends StateBasedGame {

    public AppGameContainer app; //needed to have fullscreen (F2 key)
    public GameContainer container;

    /**
     * Create a new test of graphics context rendering
     */
    public Weasel() {
        super("Space Weasel");
    }

    public void initStatesList(GameContainer container) throws SlickException {
        if (container instanceof AppGameContainer) {
            app = (AppGameContainer) container;
        }
        addState(new GameState());

    }

    /**
     * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
     */
    public void keyPressed(int key, char c) {
        super.keyPressed(key, c);

        if (key == Input.KEY_F2) {
            if (app != null) {
                try {
                    app.setFullscreen(!app.isFullscreen());
                } catch (SlickException e) { /*Log.error(e);*/

                }
            }
        }
    }

    /**
     * Entry point to our test
     *
     * @param argv The arguments passed to the test
     */
    public static void main(String[] argv) {
        try {
            AppGameContainer container = new AppGameContainer(new Weasel());
            container.setDisplayMode(400, 300, false);
            container.start();
        } catch (SlickException e) {
            e.printStackTrace();
        }
    }
}